home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-04-19 | 576 b | 33 lines |
- class Half {
- int value;
-
- void putVar1(short s) {
- value &= 0xFFFF0000;
- value |= s;
- }
-
- void putVar2(short s) {
- value &= 0x0000FFFF;
- value |= (s << 16);
- }
-
- short getVar1() {
- return (short)(value);
- }
-
- short getVar2() {
- return (short)(value >> 16);
- }
- }
-
- class Tester {
- public static void main(String[] args) {
- Half h = new Half();
- h.putVar1((short) 100);
- h.putVar2((short) -91);
-
- System.out.println(h.getVar1());
- System.out.println(h.getVar2());
- }
- }
-